#define _CRT_SECURE_NO_WARNINGS

#include <iostream>
#include<algorithm>
#include<vector>
using namespace std;

struct Class
{
    int a;
    int b;
    int diff;
};

bool compare(const Class& diff1, const Class& diff2)
{
    return diff1.diff > diff2.diff;
}

int main()
{
    int n;
    cin >> n;

    vector<Class> ret(n);
    for (int i = 0; i < n; i++)
    {
        cin >> ret[i].a >> ret[i].b;
        ret[i].diff = ret[i].a - ret[i].b;
    }

    sort(ret.begin(), ret.end(), compare);

    long long sum = 0;
    int k = n / 2;
    for (int i = 0; i < k; i++)
    {
        sum += ret[i].a;
    }

    for (int i = k; i < n; i++)
    {
        sum += ret[i].b;
    }
    cout << sum << '\n';

    return 0;
}